package com.template.entity;

import com.template.utlis.StringCommons;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangqi
 * @date 2024-01-16 10:55
 */
public class TextMessage {
    private String content;
    private List<User> idList;
    private Boolean atAll = false;

    public String getContent() {
        return content;
    }

    public TextMessage setContent(String content) {
        this.content = content;
        return this;
    }

    public List<User> getIdList() {
        return idList;
    }

    public TextMessage setIdList(List<User> idList) {
        this.idList = idList;
        return this;
    }

    public Boolean getAtAll() {
        return atAll;
    }

    public TextMessage setAtAll(Boolean atAll) {
        this.atAll = atAll;
        return this;
    }

    public TextMessage() {
        this.idList = new ArrayList<>();
    }

    public TextMessage(String content, List<User> idList, Boolean atAll) {
        this.content = content;
        this.idList = idList == null ? new ArrayList<>() : idList;
        this.atAll = atAll != null && atAll;
    }

    public static TextMessage createTextMessage(String text, Object... placeHolders) {
        return new TextMessage(StringCommons.buildString(text, placeHolders), null, null);

    }

    public TextMessage addAtUser(User user) {
        this.idList.add(user);
        return this;
    }
}
